package org.example.memora.service;

import lombok.extern.slf4j.Slf4j;
import org.example.memora.configur.RabbitConfig;
import org.example.memora.entity.ChatMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 丁利军
 * @date 2025年05月27日 22:26
 * @description TODO: 描述
 */
@Slf4j
@Service
public class ChatMessageProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(ChatMessage message) {
        log.info("发送原始消息,消息队列: {}", message);
        rabbitTemplate.convertAndSend(
                RabbitConfig.EXCHANGE_NAME,
                RabbitConfig.ROUTING_KEY,
                message
        );
    }
}

